package com.example.stuwork.controller;

import com.example.stuwork.common.Result;
import com.example.stuwork.pojo.ClassCourse;
import com.example.stuwork.service.TeacherCourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 教师课程控制器
 */
@RestController
@RequestMapping("/teacher-course")
public class TeacherCourseController {

    @Autowired
    private TeacherCourseService teacherCourseService;

    /**
     * 获取教师所教授的课程列表
     *
     * @param teacherId 教师ID
     * @return 课程列表
     */
    @GetMapping("/list/{teacherId}")
    public Result<List<Map<String, Object>>> getTeacherCourses(@PathVariable String teacherId) {
        return teacherCourseService.getTeacherCourses(teacherId);
    }

    /**
     * 获取课程详情
     *
     * @param courseId 课程ID
     * @param classId 班级ID
     * @return 课程详情
     */
    @GetMapping("/detail")
    public Result<Map<String, Object>> getCourseDetail(@RequestParam String courseId, @RequestParam Long classId) {
        return teacherCourseService.getCourseDetail(courseId, classId);
    }

    /**
     * 创建课程
     *
     * @param courseData 课程数据
     * @return 创建结果
     */
    @PostMapping("/create")
    public Result<?> createCourse(@RequestBody Map<String, Object> courseData) {
        return teacherCourseService.createCourse(courseData);
    }

    /**
     * 更新课程信息
     *
     * @param courseId 课程ID
     * @param courseData 课程数据
     * @return 更新结果
     */
    @PutMapping("/update/{courseId}")
    public Result<?> updateCourse(@PathVariable String courseId, @RequestBody Map<String, Object> courseData) {
        return teacherCourseService.updateCourse(courseId, courseData);
    }

    /**
     * 删除课程
     *
     * @param courseId 课程ID
     * @param classId 班级ID
     * @return 删除结果
     */
    @DeleteMapping("/delete")
    public Result<?> deleteCourse(@RequestParam String courseId, @RequestParam Long classId) {
        return teacherCourseService.deleteCourse(courseId, classId);
    }
} 